package com.lim.demo.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lim.demo.mapper.eventMapper;
import com.lim.demo.service.eventService;
import com.lim.demo.utils.PageRequest;
import com.lim.demo.utils.PageResult;
import com.lim.demo.utils.PageUtils;
import com.lim.demo.vo.WfBaseDateVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @program: ks-api
 * @description:
 * @author: zkai
 * @create: 2021-01-26 16:58
 */
@Service
@Primary
public class eventServiceImpl extends ServiceImpl<eventMapper, WfBaseDateVo> implements eventService {

    @Autowired
    private eventMapper eventMapper;


    @Override
    public PageResult findPage(PageRequest pageRequest,String  regionCode,String sponsorName,String  serialNum,String  title,String  state,String  sendType,String  flowClassifyName,String  flowClassifyType,String  startTime,String  endTime,String  disposalLevel,String  type,String  polic,String flowid) {
        return PageUtils.getPageResult(pageRequest, getPageInfo(pageRequest,regionCode,sponsorName,serialNum,title,state,sendType,flowClassifyName,flowClassifyType,startTime,endTime,disposalLevel,type,polic,flowid));
    }

    /**
     * 调用分页插件完成分页
     * @param pageRequest
     * @return
     */
    private PageInfo<Map<String,Object>> getPageInfo(PageRequest pageRequest,String  regionCode,String sponsorName,String  serialNum,String  title,String  state,String  sendType,String  flowClassifyName,String  flowClassifyType,String  startTime,String  endTime,String  disposalLevel,String  type,String  polic,String flowid) {
        int pageNum = pageRequest.getPageNum();
        int pageSize = pageRequest.getPageSize();
        PageHelper.startPage(pageNum, pageSize);
        List<Map<String,Object>> sysMenus = eventMapper.getList(regionCode,sponsorName,serialNum,title,state,sendType,flowClassifyName,flowClassifyType,startTime,endTime,disposalLevel,type,polic,flowid);
        return new PageInfo<Map<String,Object>>(sysMenus);
    }
    /*@Override
    public List<Object> getList(String  regionCode,String sponsorName,String  serialNum,String  title,String  state,String  sendType,String  flowClassifyName,String  flowClassifyType,String  startTime,String  endTime,String  disposalLevel,String  type,String  polic,String flowid) {
        return eventMapper.getList(regionCode,sponsorName,serialNum,title,state,sendType,flowClassifyName,flowClassifyType,startTime,endTime,disposalLevel,type,polic,flowid);
    }*/
}
